package com.xbongbong.crm.handle.analysis;

import com.alibaba.fastjson.JSONObject;
import com.xbongbong.paas.domain.entity.ext.PaasFormDataEntityExt;
import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.paas.pojo.dto.AnalysisDataDTO;
import com.xbongbong.paas.pojo.dto.FormDataListDTO;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.parent.parse.data.AbstractListAnalysisDataService;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import com.xbongbong.saas.help.FormDataAnalysisHelp;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;

/**
 * @author gaojie
 * @version v1.0
 * @date 2022/9/16 15:01
 * @description
 */
@Service("competitorListAnalysisDataHandler")
public class CompetitorListAnalysisDataHandler extends AbstractListAnalysisDataService<PaasFormDataEntityExt> {
    @Override
    public List<Integer> businessList() {
        return Collections.singletonList(XbbRefTypeEnum.COMPETITOR.getCode());
    }

    @Override
    public void analysisData(AnalysisDataDTO analysisDataDTO, JSONObject resultJsonObject, Map<String, Object> linkData, Set<Object> linkDataSet) throws XbbException {

        FieldAttrEntity fieldAttrEntity = analysisDataDTO.getFieldAttrEntity();
        String key = analysisDataDTO.getAttr();
        JSONObject objectJsonObject = analysisDataDTO.getDataJsonObject();
        Integer businessType = analysisDataDTO.getBusinessType();

        // 判断高级规则
        // 审批摘要不判断高级权限
        if (Objects.isNull(analysisDataDTO.getIsProcess()) || !analysisDataDTO.getIsProcess()) {
            FormDataAnalysisHelp.invisibleSetNull(fieldAttrEntity, analysisDataDTO, objectJsonObject);
        }

        super.analysisData(analysisDataDTO, resultJsonObject, linkData, linkDataSet);
    }
}
